home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 1
/
SPACE - Library 1 - Volume 1.iso
/
program
/
245
/
gfatip15
/
gfatip15.doc
< prev
next >
Wrap
Text File
|
1988-02-07
|
13KB
|
318 lines
January 16, 1988
GFATIP15.DOC
by
Barbara J. Behuniak
Principle Systems Programmer
& President
Marathon Computer Press
&
John B. Holder
Senior Software Engineer
Marathon Computer Press
Asst. Sysop on GEnie's MichTron Roundtable
&
Brian Lake
Associate Programmer, Marathon Computer Press
This is the 15th in a planned series of GFA Tip files. The
topic of this issue is building a software reset routine for GFA
Basic. In this archive you will find the following files:
Reboot2.S
Reboot2.O
GFATIP15.DOC
GFATIP15.LST
GFABOOT.PRG
Background:
The idea for this series of utility procedures came about out
of a need for a software driven reset. By this we mean that we
needed to be able to reset the computer just as if the user had
pressed the reset button on the back of their computer.
Occasionally a programmer, {predominantly systems level} will
need to accomplish this as a convenience to the user or to abort
an otherwise corrupted system.
Why For GFA Basic?:
There is really no reason why GFA Basic programmers have to
feel that some things simply can't be done with GFA Basic. It is
a common misconception that some languages are all things to all
people if they can master them. Many Basic programmers think that
systems level programming must be left to those spooky people that
have little dark rooms in their basement with a supermicro. The
same starting Basic programmer often gets this picture of a
man/woman like this and will either quit or become discouraged
when confronted with an otherwise insurmountable problem. So a
small portion feel that they must then abandon Basic and venture
out in search of knowledge to overcome the Basic Doldrums. I
personally wonder just how many of these would be {explorers} are
lost in the sea of confusion. There is absolutely no reason for
this to happen. What we are proposing is that the programmer need
not beseech his language, but augment it with another language
from time to time. Very few programs can be roughed out with the
ease and facility of Basic, and even fewer with a Basic slighter
than GFA Basic. Since we have such a fast and able version of
Basic, let's use it. If per chance you ever find routines that
are just not fast enough or are not really suited for the embedded
command suite of GFA Basic, our mentor {Frank Ostrowski, Creator
of GFA Basic}, has added the ability to use modules created with
another language such as C with the "C:" command or perhaps
Assembled programs with the "Call" command. By doing so we have a
wonderful (modern) language that allows for the programmer to drop
down a notch or two to conduct some things not really possible
with the parent language. I think the hooks left by the developer
were very thoughtful indeed and have made the GFA Basic language a
favorite among Hackers and Commercial Developers alike.
Well, I suppose we have been on our soapbox long enough so we
should really get started with the documentation for this GFATIP.
GFA Basic and Assembler:
For this GFATIP we will be utilizing a subroutine written in
MC68000 Assembler, (The language that GFA Basic itself is written
in). The purpose is to show you how to utilize a routine such as
this, and to give you access to a powerful extension to the GFA
Basic language. It's really short in description so let's get
started.
The Problem:
We needed a routine to emulate the press of the reset button,
but without the user physically doing so.
The Assembler Solution To Our Problem:
gfaboot: clr.l 0x420
In the above line we have a label, (gfaboot), and a
instruction in MC68000 language followed by an attribute. Clr
means "Clear an Operand", and the .l means long. It can also be
either byte or word. The actual location that we happen to be
clearing is 0x420 {memvalid}, or in GFA Basic (&H420). This is
the system location that checks to see of the memory controller's
configuration is valid.
clr.l 0x43a
In the next location is the second half {memval2}.
movea.l 0, a7
Now we move on to a new MC68000 instruction with a new
purpose. We will use movea which is designed to move the content
of the source to the destination address register. The size of
the operation may be specified to be of word on long size in
length. Word size source operands are going to be sign extended
to full 32 bit lengths in advance of completion. In this instance
we are grabbing the system startup stack.
movea.l 4, a0
By using the same MC68000 instruction we will accomplish the
grab of the system startup program counter.
jmp (a0)
In the next instruction we conduct a jump to the startup
routine or {reboot}. The jmp MC68000 simply moves you to the
specified effective address {A0} that's specified by the
instruction. And wala! A software Reset is in the making! Since
we never return this is the last hurrah for our routine and the
calling program.
{Attribute Conventions:}
Above you see instructions followed by a "." and then a
single letter. These mean the following:
.b = Byte, 8 bits
.w = Word, 16 bits, double byte
.l = Long, 32 bits, double word
The finished ASM source:
gfaboot: clr.l 0x420
clr.l 0x43a
movea.l 0, a7
movea.l 4, a0
jmp (a0)
Pretty simple huh? Well maybe not all that simple, but
pretty darned effective to kick your old ST in the seat of the
pants! Now before we progress any further, let's answer a few
questions about how to get this into something that GFA Basic can
use.
For this sample ASM routine we used Mark Williams C and the
'AS' command {it's simple assembler}. You should be able to use
any of the other assemblers on the market also, ie.. GenSt
(HiSoft), AssemPro (Abacus), or the MetaComCo 68000 Assembler.
Once our source file was created, we issued the following command
while under the control of MSH { The command line interpreter }:
cc -A -c reboot.s
Nota Bene: { The -A option tells the Mark Williams C compiler that
if there are any errors, please send us back to the editor (Micro
EMACS), and show us where we failed. Nice for detecting errors
and saving valuable time with larger programs than this.}
By doing so we told the C compiler driver to supress the
linking and removal of the .O object file created during assembly.
All we wanted was the raw assembled file.
After that was accomplished, we tackled the creation of the
GFA Basic compatible program incorporation of the object file with
the help of the GFA Basic Book {by Frank Ostrowski of GFA
Systemtechnik}. A short utility contained in the GFA Basic book
helped us to turn the object file into the nitty gritty
unrelocated MC68000 assembled data that we desired. << By the
way, The GFA Basic Book is a MUST for any of you that desire to
learn how to interface Machine Language with GFA Basic. >> Once
we had the data statements it was just a matter of putting the
program together.
First step was to allocate a variable to hold the ASM data.
This we called Reboot$. Next we used a subroutine call to load
the ASM data in the variable, thus Insert_rebooter_asm was born.
Then we made a call to the Xbios 38 function Supexec (Made
infinitely easier by The GFA Basic Companion II source code
libraries {Provided here by express permission of Marathon
Computer Press and MichTron Inc.}) The reason why we must use the
Supexec call is that all calling procedures trying to access
memory locations between &H0 and &H800 have to move into a
'Supervisor Mode' of operation.
Although dangerous in the developmental stages, it's
imperative to do so in the finished product. This call is not for
the 'just starting beginner' or weak of heart and even those that
do not follow the 11th commandment "Thou shalt not be caught dead
without current backups!"
The GFA Basic Source:
' GFATIP15.BAS
' Copyright 1988 Marathon Computer Press
' Written by
' Barbara J. Behuniak
' John B. Holder
' Brian Lake
'
' This tip file and the rest of the archive are in the public domain in so
' far as no charge of any kind is assessed for the distribution of it in it's
' entirety. Marathon Computer Press retains all rights the code contained
' herein. You may use any or all of the code in any application you write for
' commercial or non-commercial use. Please give us credit if you do so.
'
'
'
' Now let's call our procedures to make the end result of a software reboot.
'
'
@Do_a_reboot ! Call in the ST Wreckers..
' Once called your system will reboot just as if you pressed the reset.
'
'
Procedure Do_a_reboot
Reboot$=""
@Insert_rebooter_asm
Machine_code%=Varptr(Reboot$)
@Supexec(Machine_code%)
'
Return ! Even though we never will.
'
'
'
Procedure Insert_rebooter_asm
'
Do
Read Asm%
Exit If Asm%<0
Reboot$=Reboot$+Mki$(Asm%)
Loop
'
Return
'
'
'
' Disassembled Machine code for the file REBOOT2.O
'
Data 0,0,0,0,0,5632,0,0
Data 0,0,17081,0,1056,17081,0,1082
Data 11897,0,0,8313,0,4,20176,26470
Data 24930,28527,29696,0,0,0
Data -1
'
'
' This next Xbios routine is not for Beginners!!!!!!!
' It will execute a routine in the 68000 supervisor mode
' The address must be passed in this manner:
' Prog_address=Varptr("function")
' For example you Bload a ML program in the variable Prog$, then you would
' use Prog_address=Varptr(Prog$)
'
'
' This routine was extracted from the GFA Basic Companion II .LST library and
' is Copyright 1988 Marathon Computer Press. Provided in this GFATIP by
' MichTron and Marathon Computer Press as a public service.
'
Procedure Supexec(Machine_code%)
Dummy=Xbios(38,L:Machine_code%)
Return
Closing Remarks:
Please don't be one of those 'would be' Basic programmers
that decided playing games is really better than programming
anyways.. Don't get frustrated, get even... with all those C,
Pascal, and Modula 2 programmers that say that Basic is dead and
can't be used for serious programming projects. And most of all
support GFA Basic & it's development tools. As a last thought,
please consider the programmers and support staff of any
commercially produced software product the next time someone
offers you a "free" copy of a Copyrighted Software Program. By
becoming one of the growing ranks of software "PIRATES", you would
only be joining the ranks of the #1 public enemy of Microcomputer
users. Let's join together and protect the goose that laid the
golden egg. You may write to the below organization to make a
statement in support of this cause.
CHART
(Computer Hobbyists Against Raiders And Thieves)
P.O. Box 97276
Pittsburgh, PA 15229
Comments and PD release
This GFATIP file is in the public Domain. However, the
documentation file and source is Copyright 1988 by Marathon
Computer Press, and is provided as a public service. You may not
include the text of this file in any publication, or newsletter
without the approval of Marathon Computer Press. The source code
and idea are Copyright 1988 by Marathon Computer Press also, but
you may use it as you see fit if you give us a mention of credit
in your program code {if provided in source} or documentation.
You may also post this file on any bulletin board as long as it is
posted in it's entirety. Absolutely NO charge (of any kind) may
be assessed for providing this Tip to the public. If it's not
100% Free, don't do it! Nuff Said.